<html>
<head><meta charset="utf-8"><title>Code to convert RA ast to rustc ast · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Code.20to.20convert.20RA.20ast.20to.20rustc.20ast.html">Code to convert RA ast to rustc ast</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="192844263"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Code%20to%20convert%20RA%20ast%20to%20rustc%20ast/near/192844263" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Luca Barbieri <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Code.20to.20convert.20RA.20ast.20to.20rustc.20ast.html#192844263">(Apr 03 2020 at 18:15)</a>:</h4>
<p><span class="user-mention" data-user-id="133169">@matklad</span>  I wrote some code to convert RA asts to rustc asts as a pull request for rustc. It is essentially complete and can build real projects, provided they only use the Rust 2018 edition, since the RA parser currently doesn't support 2015.  It can be used as a development tool to check that RA and rustc produce the same AST, and could theoretically replace the rustc parser (but that would need much better error reporting, ensuring that all invalid code is rejected and more misc work). Pull request at <a href="https://github.com/rust-lang/rust/pull/70745" title="https://github.com/rust-lang/rust/pull/70745">https://github.com/rust-lang/rust/pull/70745</a></p>



<a name="192844690"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Code%20to%20convert%20RA%20ast%20to%20rustc%20ast/near/192844690" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Code.20to.20convert.20RA.20ast.20to.20rustc.20ast.html#192844690">(Apr 03 2020 at 18:18)</a>:</h4>
<p>wow</p>



<a name="192844728"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Code%20to%20convert%20RA%20ast%20to%20rustc%20ast/near/192844728" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Code.20to.20convert.20RA.20ast.20to.20rustc.20ast.html#192844728">(Apr 03 2020 at 18:19)</a>:</h4>
<p><span aria-label="tada" class="emoji emoji-1f389" role="img" title="tada">:tada:</span> <span aria-label="100" class="emoji emoji-1f4af" role="img" title="100">:100:</span></p>



<a name="192844778"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Code%20to%20convert%20RA%20ast%20to%20rustc%20ast/near/192844778" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Code.20to.20convert.20RA.20ast.20to.20rustc.20ast.html#192844778">(Apr 03 2020 at 18:19)</a>:</h4>
<p>Can rustc with rust-analyzer's parser build rust-analyzer?</p>



<a name="192845135"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Code%20to%20convert%20RA%20ast%20to%20rustc%20ast/near/192845135" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Code.20to.20convert.20RA.20ast.20to.20rustc.20ast.html#192845135">(Apr 03 2020 at 18:22)</a>:</h4>
<p>(I am still speechless by the way)</p>



<a name="192846173"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Code%20to%20convert%20RA%20ast%20to%20rustc%20ast/near/192846173" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Luca Barbieri <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Code.20to.20convert.20RA.20ast.20to.20rustc.20ast.html#192846173">(Apr 03 2020 at 18:30)</a>:</h4>
<p>IIRC it can't at least due to some dependencies using Rust 2015</p>



<a name="192846288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Code%20to%20convert%20RA%20ast%20to%20rustc%20ast/near/192846288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Code.20to.20convert.20RA.20ast.20to.20rustc.20ast.html#192846288">(Apr 03 2020 at 18:31)</a>:</h4>
<p>I'd love to fix that (supporting subsets of 2015 shouldn't be too hard I hope)! Not because it would be useful, but because that would be super cool!</p>



<a name="192846382"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Code%20to%20convert%20RA%20ast%20to%20rustc%20ast/near/192846382" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Code.20to.20convert.20RA.20ast.20to.20rustc.20ast.html#192846382">(Apr 03 2020 at 18:32)</a>:</h4>
<p>I've obviously haven't looked into the PRs yet (and probably won't be able to dig into them today), but, right of the bat, I have an organizational question</p>



<a name="192846489"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Code%20to%20convert%20RA%20ast%20to%20rustc%20ast/near/192846489" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Code.20to.20convert.20RA.20ast.20to.20rustc.20ast.html#192846489">(Apr 03 2020 at 18:33)</a>:</h4>
<p><span class="user-mention" data-user-id="279832">@Luca Barbieri</span> how do you feel about driving the task of unifing rustc and rust-analyzer parsers? I guess, at the moment you know more about this than anyone else in the universe :)</p>



<a name="192846896"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Code%20to%20convert%20RA%20ast%20to%20rustc%20ast/near/192846896" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Luca Barbieri <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Code.20to.20convert.20RA.20ast.20to.20rustc.20ast.html#192846896">(Apr 03 2020 at 18:36)</a>:</h4>
<p>actually I don't think I'll do any more significant work on rust-analyzer/rustc at the moment</p>



<a name="192847018"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Code%20to%20convert%20RA%20ast%20to%20rustc%20ast/near/192847018" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Code.20to.20convert.20RA.20ast.20to.20rustc.20ast.html#192847018">(Apr 03 2020 at 18:37)</a>:</h4>
<p>That's fair!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>